package com.futao.springbootlearn20220224.filterdemo;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author futao@gmail.com
 * @date 2022/3/28
 */
@Slf4j
@WebFilter(urlPatterns = "/*")
public class InjectFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("InjectFilter拦截请求-开始");
        filterChain.doFilter(servletRequest, servletResponse);
        log.info("InjectFilter拦截请求-结束");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
